package com.company.behavioral.interparter_pattern.terminal_expression;

import com.company.behavioral.interparter_pattern.abstract_expression.AbstractNode;

/**
 * 方向结点
 * @ClassName DirectionNode
 * @Author tiezheng.han
 * @Date 2020/9/4 10:40
 **/
public class DirectionNode extends AbstractNode {

    private String direction;

    public DirectionNode(String direction) {
        this.direction = direction;
    }

    /**
     * 方向表达式的解释操作
     * @return
     */
    @Override
    public String interpret() {
        if(direction.equalsIgnoreCase("up")){
            return "向上";
        } else if (direction.equalsIgnoreCase("down")){
            return "向下";
        } else if (direction.equalsIgnoreCase("left")){
            return "向左";
        } else if (direction.equalsIgnoreCase("right")){
            return "向右";
        } else {
            return "无效指令";
        }
    }
}
